package com.tarena.lbs.content.service.impl;

import com.tarena.lbs.content.dao.repository.ArticleRepository;
import com.tarena.lbs.content.pojo.param.ArticleContentParam;
import com.tarena.lbs.content.pojo.po.ArticleSearchPO;
import com.tarena.lbs.content.service.ArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@Slf4j
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleRepository articleRepository;

    @Override
    public void addArticle(ArticleContentParam param) {
        log.debug("文章保存业务参数:{}",param);
        ArticleSearchPO articleSearchPO = new ArticleSearchPO();
        BeanUtils.copyProperties(param,articleSearchPO);
        articleSearchPO.setCreateTime(new Date());
        articleRepository.save(articleSearchPO);
    }
}
